const { getDjprogramHttp, getNewestHttp, getPlaylistHttp} = require("../../utils/http")
Page({
  data: {
    playlists: [],
    newest: [],
    dj:[]
  },
  onLoad() {
    getPlaylistHttp().then(res => {
      var top = res.data.playlists
      var playlists = top.splice(0,3)
      this.setData({
        playlists
      })
    })
    getNewestHttp().then(res => {
      var albums = res.data.albums
      var newest = []
      albums.splice(0,3).forEach(item => {
        var { blurPicUrl, name } = item
        newest.push({
          name,
          coverImgUrl:blurPicUrl
        })

      })
      this.setData({
        newest
      })
    })
    getDjprogramHttp().then(res => {
      var result = res.data.result
      var dj = []
      result.splice(0,3).forEach(item => {
        var { picUrl, name } = item
        dj.push({
          name,
          coverImgUrl: picUrl
        })
      })
      this.setData({
        dj
      })
    })
  },
  handleClick(event) {
    console.log(event.currentTarget.dataset)
    var { aid } = event.currentTarget.dataset
    wx.navigateTo({
      url: `/pages/det/det?id=${aid}`
    })
  },
  handleItem() {
    wx.navigateTo({
      url:`/pages/detail/detail`
    })
  }
})